let cookie = {
    set(key,value,json = {}){
        let str = encodeURIComponent(key) + '=' + encodeURIComponent(value);
        if(!isNaN(json.expires)){
            let date = new Date();
            date.setDate(date.getDate() + json.expires);
            str += ';expires=' + date;
        }
        if(json.path){
            str += ';path=' + json.path;
        }
        document.cookie = str;
    },
    get(key){
        let arr = document.cookie.split('; ');
        for(let i = 0;i < arr.length;i++){
            let list = arr[i].split('=');
            if(encodeURIComponent(key) == list[0]){
                return decodeURIComponent(list[1]);
            }
        }
    },
    remove(key,json={}){
        if(json.path){
            // this.set(key,'',{expires : -1,path : '/'})
            document.cookie = `${encodeURIComponent(key)}=;expires=${new Date(0)};path=${json.path}`;
        }else{
            document.cookie = `${encodeURIComponent(key)}=;expires=${new Date(0)}`
        }
    },
    convertStrToObj(str){
        if(!str){
            return {}
        }
        return JSON.parse(str);
    }
}